import 'package:flutter/material.dart';
import 'package:heven/utils/index.dart';
import 'package:heven/widget/button.dart';

class VipWidget extends StatefulWidget {
  const VipWidget({super.key, this.isVip = false, this.coin = 0});
  final bool isVip;
  final int coin;

  @override
  State<VipWidget> createState() => _VipWidgetState();
}

class _VipWidgetState extends State<VipWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.fromLTRB(20, 0, 20, 0),
      padding: const EdgeInsets.only(left: 12, right: 12),
      height: 59,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(16.5),
        gradient: const LinearGradient(
          colors: [
            Color(0xFF3966FF),
            Color(0xFF0BBCD1),
          ],
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Image.asset(
            'assets/images/name.png',
            height: 20,
            width: 106,
          ),
          //  const Text(
          //     'HEVEN VIP',
          //     style: TextStyle(
          //       color: Colors.white,
          //       fontSize: 23,
          //     ),
          //   ),
          Text(
            '${widget.coin}/首',
            style: const TextStyle(
              color: Colors.white,
              fontSize: 17,
              fontWeight: FontWeight.w600,
            ),
          ),
          ButtonWidget(
            width: 70,
            height: 21,
            margin: const EdgeInsets.all(0),
            child: Text(
              widget.isVip ? 'VIP' : '开通会员',
              style: TextStyle(
                fontSize: widget.isVip ? 14 : 11,
                color: const Color(0xFF000000),
                fontWeight: FontWeight.bold,
              ),
            ),
            onTap: () async {
              var token = await Common.getStorageValue('token');
              if (token == null) {
                Navigator.pushNamed(context, '/login/list');
                return;
              }
              if (!widget.isVip) {
                Navigator.pushNamed(context, '/vip');
              }
              //
            },
          ),
        ],
      ),
    );
  }
}
